var express = require('express');
var router = express.Router();
var request = require('request');
var itemDao = require('../dao/itemDao');
var userAgentUtil = require('../utils/userAgent');
var $constant = require('../utils/constant');

router.get('/', function(req, res, next) {
  var param = req.query || req.params;
  itemDao.query(param, function(result){
   if(userAgentUtil.isM(req)){
    res.render('m/category.html',{result:result,node:param.node,px:param.px,nodeName:$constant.label[param.node]});
   }
   else
    res.render('m/category.html',{result:result,node:param.node,px:param.px,nodeName:$constant.label[param.node]});
});

});

router.post('/', function (req, res) {
  var param = req.body;
  itemDao.query(param, function(result){

   res.send(result);
 });
});

module.exports = router;
